home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Gigarom 1
/
Gigarom Macintosh Archives (Quantum Leap)(CDRM1080320)(1993).iso
/
FILES
/
HYP
/
H-I
/
HyperHackers.cpt
/
Hyper-Hackers Queue 1.0
/
card_7135.txt
< prev
next >
Wrap
Text File
|
1989-02-26
|
2KB
|
75 lines
-- card: 7135 from stack: in.0
-- bmap block id: 0
-- flags: 0000
-- background id: 3797
-- name:
-- part contents for background part 1
----- text -----
Date: Wed, 4 Nov 87 11:06 EST
From: David Bogartz <IDDAVIDB@aahbo.com>
The scripts below show a quick and very dirty way to get HyperCard to
send a message when the user presses a key (other than return, tab,
and the arrow keys). It doesn't work for number keys, and it probably
isn't right for some applications, but it's simple and will probably
work in many cases.
The basic idea is that there is an idle handler in the background
script that looks in the message box and grabs whatever is there.
Then, for each keystroke, it generates the event "key" with the char
that the user pressed as a parameter.
The trick is how to deal with the message box. It looks like the
message box is hidden, but in point of fact you can't have the message
box hidden because (as far as I can tell) whenever you put something
into the message box, HyperCard shows it, even if the screen is
locked. So I have it visible, but offscreen. (Of course, this only
works on a small screen Mac.)
This application lets the user press the keys A through G to play the
respective notes A through G on the harpsichord keyboard.
Background script
=================
on idle
put the message box into k
if k is not empty then
repeat with i = 1 to length(k)
do "key " & quote & char i of k & quote
end repeat
put empty into the message box
end if
end idle
on key c
play "harpsichord" tempo 200 c
end key
Stack script
============
on openStack
set the loc of msg to -473, 345
set blindtyping to true
end openStack
============
I'd be interested in any feedback or improvements on this code that
you may have. If you send messages directly to me, I will summarize
to the net.
David S. Bogartz
dsbogartz@amherst.bitnet
-- part contents for background part 45
----- text -----
Keydown messages